package com.app.newiptv.bean;

import android.os.Parcel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 影片基本信息封装
 *
 * @author Richard
 */
public class Detail extends Content {
    /**
     * 影片类别,如:战争,爱情,其它等
     */
    public List<String> categorys;
    /**
     * 导演
     */
    public List<String> directors;
    /**
     * 区域
     */
    public List<String> zones;
    /**
     * 描述
     */
    public String description = "";
    /**
     * 演员列表
     */
    public List<String> actors;
    /**
     * 剧集
     */
    public List<MediaSource> sources;

    /**
     * 上次播放到第几集
     */
    public int position = 0;

    public int episodeCount;

    public int lastUpdateEpisode;
    /**
     * 节目鉴权结果  1036业务鉴权失败，0是成功
     */
    public String serviceAuthResult;  
    public Detail() {
        super();
        categorys = new ArrayList<>();
        directors = new ArrayList<>();
        zones = new ArrayList<>();
        actors = new ArrayList<>();
        sources = new ArrayList<>();
    }

    // ---------------------Parcelable implements------------
    public static final Creator<Detail> CREATOR = new Creator<Detail>() {

        @Override
        public Detail createFromParcel(Parcel source) {
            ArrayList<String> categorys = new ArrayList<>();
            ArrayList<String> directors = new ArrayList<>();
            ArrayList<String> zones = new ArrayList<>();
            ArrayList<String> actors = new ArrayList<>();
            ArrayList<MediaSource> sources = new ArrayList<>();

            String parentID = source.readString();
            String contentID = source.readString();
            String name = source.readString();
            ImageSource imgSource = source.readParcelable(ImageSource.class.getClassLoader());
            String type = source.readString();
            int isHistory = source.readInt();
            Map extras = source.readHashMap(HashMap.class.getClassLoader());
            source.readStringList(categorys);
            source.readStringList(directors);
            source.readStringList(zones);
            String description = source.readString();
            source.readStringList(actors);
            source.readTypedList(sources, MediaSource.CREATOR);
            int position = source.readInt();
            int isFavorite = source.readInt();
            int lastUpdateEpisode = source.readInt();
            int episodeCount = source.readInt();
            String serviceAuthResult = source.readString();
            
            Detail detail = new Detail();
            detail.parentID = parentID;
            detail.contentID = contentID;
            detail.name = name;
            detail.imgSource = imgSource;
            detail.type = type;
            detail.isHistory = isHistory;
            detail.extras = extras;
            detail.categorys = categorys;
            detail.directors = directors;
            detail.zones = zones;
            detail.description = description;
            detail.actors = actors;
            detail.sources = sources;
            detail.position = position;
            detail.isFavourite = isFavorite;
            detail.lastUpdateEpisode = lastUpdateEpisode;
            detail.episodeCount = episodeCount;
            detail.serviceAuthResult = serviceAuthResult;
            return detail;
        }

        @Override
        public Detail[] newArray(int size) {
            return new Detail[size];
        }

    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(parentID);
        dest.writeString(contentID);
        dest.writeString(name);
        dest.writeParcelable(imgSource, flags);
        dest.writeString(type);
        dest.writeInt(isHistory);
        dest.writeMap(extras);
        dest.writeStringList(categorys);
        dest.writeStringList(directors);
        dest.writeStringList(zones);
        dest.writeString(description);
        dest.writeStringList(actors);
        dest.writeTypedList(sources);
        dest.writeInt(position);
        dest.writeInt(isFavourite);
        dest.writeInt(lastUpdateEpisode);
        dest.writeInt(episodeCount);
        dest.writeString(serviceAuthResult);
    }
}
